#include <vector>
#include <string>
#include <iostream>
#include <iterator>
#include <algorithm>
struct initial
{
    bool operator()(std::string& fruit){
        return fruit[0] == 'a';
    }
};
struct initial_not
{
    bool operator()(std::string& fruit){
        return fruit[0] != 'a';
    }
};

            
int main()
{
    
    std::vector<std::string> fruits;
    fruits.push_back("aaa");
    fruits.push_back("abc");
    fruits.push_back("banana");
    fruits.push_back("pear");
    fruits.push_back("apple");
    fruits.push_back("jerry");
    

    copy(fruits.begin(), fruits.end(), std::ostream_iterator<std::string>(std::cout, " "));
    sort(fruits.begin(), fruits.end());
    typedef std::vector<std::string>::iterator VSI;
    VSI p1 = find_if(fruits.begin(), fruits.end(), initial());
    VSI p2 = find_if(p1, fruits.end(),initial_not());
    fruits.erase(p1, p2);
    std::cout << std::endl << "After deleted: " << std::endl;
    copy(fruits.begin(), fruits.end(), std::ostream_iterator<std::string>(std::cout, " "));    
    return 0;
}
